<?php
/**
 * 我的培训模型
 * @author LXf
 * @date 2018.8.24
 */

namespace App\Model\Crm;

use App\model\BaseModel;
use DB;

class MyTrainModel extends BaseModel{
     /***
     *培训列表 
     ***/
    const MY_TRAIN = 'my_train';
    public static function listTrain($orderby="id"){
        
        return DB::table(self::MY_TRAIN)->orderBy($orderby)->get();

    }
    /***
     * 专题，培训，证书数据合并
     * ***/
    public function joininfo(){
          $h = DB::table('user')
            ->join('my_honor as h', 'user.id', '=', 'h.user_id')->select('user.user_name', 'h.*')
            ->get();
           $t = DB::table('user')->join('my_train as t', 'user.id', '=', 't.user_id')->select('user.user_name', 't.*')
            ->get();
           $m = DB::table('user') ->join('my_special as m','user.id','=','m.user_id')
            ->select('user.user_name','m.*')
            ->get();
           $users[] =$h[0];
           $users[] =$t[0];
           $users[] =$m[0];
         return $users;
    } 
    /***
     *添加个人培训
     ***/
    public static function addTrain($data){
        
        return DB::table(self::MY_TRAIN)->insert($data);

    }
     /***
     *修改个人培训
     ***/
    public static function updateTrain($where,$data){
        
        return DB::table(self::MY_TRAIN)->where($where)->update($data);

    }
    public static function delTrain($where){
       return DB::table(self::MY_TRAIN)->where($where)->delete();
    }

}